<style type="text/css">
    .mainintro {width:160px;margin-left:15px;}
    .mainintro h3{margin-bottom:10px;font-size:14px;}
    .sect-content{color:#777;line-height:25px;margin-bottom:15px;}
    #budget_inner {margin-top:15px;}
    #budget dl {padding:13px 0;}
    #budget dl dt {padding-left:10px;width:50px;float:left;font-size:14px;}
    #budget dl dd {float:left;width:682px;}
    #budget .budget_inner_i {font-size:12px;margin-top:13px;}
</style>
<div class="mainintro r">
    <div id="findfriends" class="sect">
        <h3>个人情况</h3>
        <div class="sect-content">
            <p class="dummy">
                本月支出: <strong><?= $show['expense'] ?></strong> 元
            </p>
            <p class="dummy">
                本月收入: <strong><?= $show['income'] ?></strong> 元
            </p>
            <p class="dummy">
                现金账户: <strong><?= $show['asset']['cash'] ?></strong> 元
            </p>
            <p class="dummy">
                银行账户: <strong><?= sprintf("%.2f", $show['asset']['bank']) ?></strong> 元
            </p>
            <p class="dummy">
                电子账户: <strong><?= sprintf("%.2f", $show['asset']['elec']) ?></strong> 元
            </p>
            <p class="dummy">
                其它账户: <strong><?= sprintf("%.2f", $show['asset']['other']) ?></strong> 元
            </p>
            <p class="dummy">
                债务结算: <strong><?= sprintf("%.2f", $show['debtor']['total']) ?></strong> 元
            </p>
            <p class="dummy">
                总共资产: <strong><?= sprintf("%.2f", $show['asset']['total'] + $show['creditor']['total']) ?></strong>元
            </p>
            <p class="dummy">
                <a href="/account/" class="ajax">查看账户信息</a></p>
        </div>
    </div>
    <div id="notice" class="sect">
        <h3>系统公告</h3>
        <div class="sect-content">
            <?php foreach ($notice_list as $m => $n) { ?>
                <p class="dummy">
                    <a href="/notice/show/<?= $n['id'] ?>/" title="<?= $n['title'] ?>" class="dialog">[<?= date("m-d", $n['createtime']) ?>]<?= $n['title'] ?></a>
                </p>
            <?php } ?>
        </div>
    </div>
</div>
<div class="p-head">
    <b class="c3">最近支出</b>
</div>
<div style="width:565px;margin-bottom:10px;">
    <table class="data list" cellpadding="0" cellspacing="1" width="100%" style="margin-bottom:0;margin-top:-10px;">
        <thead class="thead">
            <tr style="background:#f3f3f3;">
                <th width="90">
                    <span class="clear">
                        <a href="javascript:;" class="btn btn_n_s">
                            <span><em>日期</em></span>
                        </a>
                    </span>
                </th>
                <th width="100">
                    <span class="clear">
                        <a href="javascript:;" title="" class="btn btn_n_s">
                            <span><em>类别</em></span>
                        </a>
                    </span>
                </th>
                <th width="100">
                    <span class="clear">
                        <a href="javascript:;" title="" class="btn btn_n_s">
                            <span><em>帐户</em></span>
                        </a>
                    </span>
                </th>
                <th width="90">
                    <span class="clear">
                        <a href="javascript:;" title="" class="btn btn_n_s">
                            <span><em>金额</em></span>
                        </a>
                    </span>
                </th>
                <th>
                    <span class="clear">
                        <a href="javascript:;" title="" class="btn btn_n_s">
                            <span><em>备注</em></span>
                        </a>
                    </span>
                </th>
            </tr>

        </thead>
        <tbody>
            <?php foreach ($expense_list as $m => $n) { ?>
                <tr class="ajax">
                    <td><a href="/bill/?startdate=<?= date("Y-m-d", $n['occurtime']) ?>&enddate=<?= date("Y-m-d", $n['occurtime']) ?>" title="点击查看该时间段数据" class="fdate" style="<?= $n['occurtime'] >= get_unixtime('day', -2) ? "color:#EC4F4F" : '' ?>" rel="<?= date("Y-m-d", $n['occurtime']) ?>"><?= date("Y-m-d", $n['occurtime']) ?></a></td>
                    <td><a href="/bill/?category_id=<?= $n['father_category']['id'] ?>" title="点击查看该分类数据" class="fcategory" rel="<?= $n['father_category']['id'] ?>"><?= $n['father_category']['name'] ?></a> - 
                        <a href="/bill/?category_id[]=<?= $n['category']['id'] ?>" title="点击查看该分类数据" class="fcategory" rel="<?= $n['category']['id'] ?>"><?= $n['category']['name'] ?></a></td>
                    <td><a href="/bill/?account_id[]=<?= $n['account']['id'] ?>" title="点查看选该账户数据" class="faccount" rel="<?= $n['account']['id'] ?>"><?= $n['account']['name'] ?></a></td>
                    <td style="color:#EC4F4F"><?= $n['amount'] ?></td>
                    <td><?= $n['memo'] ?></td>
                </tr>
            <?php } ?>
        </tbody>
    </table>
</div>
<div class="p-head">
    <b class="c3">本月预算</b>
</div>
<div id="budget" style="width:568px;float:left;">
    <div id="budget_inner" class="ajax">
        <?php foreach ($out as $k => $v) { ?>
            <?php
            $t = 0;
            if (isset($real['expense'][$v['id']])) {
                if (isset($budget['expense'][$v['id']])) {
                    $t = $budget['expense'][$v['id']] > 0 ? ceil($real['expense'][$v['id']] / $budget['expense'][$v['id']] * 100) : 100;
                } else {
                    $t = $real['expense'][$v['id']] > 0 ? 100 : 0;
                }
            }
            ?>
            <a href="/bill/?category_id=<?= $v['id'] ?>&startdate=<?= date("Y-m-d", $startdate) ?>&enddate=<?= date("Y-m-d", $enddate) ?>" title="实际:<?= isset($real['expense'][$v['id']]) ? $real['expense'][$v['id']] : 0 ?>&#13;预算:<?= isset($budget['expense'][$v['id']]) ? $budget['expense'][$v['id']] : 0 ?>&#13;点击查看消费详情">
                <div class="chart">
                    <div class="percentage" data-percent="<?= $t ?>" data-color="<?= $t >= 85 ? "#F0615A" : "#8DCF35" ?>">
                        <div class="label"><?= $v['name'] ?></div>
                        <div class="percent"><?= $t ?> %</div>
                    </div>
                </div>
            </a>
        <?php } ?>
    </div>
</div>    
<script type="text/javascript">
    $(function() {
        if ($.browser.msie && $.browser.version < 8.0) {
            //$("#budget_inner").hide();
        } else {
            $('.percentage').each(function() {
                $(this).easyPieChart({
                    animate: 1000,
                    trackColor: "#e3e3e3",
                    barColor: $(this).attr("data-color")
                });
            });
            $("#budget_inner>dl>dd>.lp-loading").click(function() {
                $(this).next(".budget_inner_i").slideToggle();
            });
        }
    });
</script>